package May;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class ThreadWriter implements Runnable{
    Socket s;
    public ThreadWriter(Socket s){
        this.s=s;
    }

    public void run(){
        try{
            Scanner in=new Scanner(System.in);
            OutputStream os = s.getOutputStream();
            OutputStreamWriter ow=new OutputStreamWriter(os);
            BufferedWriter bw=new BufferedWriter(ow);

            InputStream is=s.getInputStream();
            InputStreamReader ir=new InputStreamReader(is);
            BufferedReader br=new BufferedReader(ir);

            while(true) {
                String str1 = in.next();
                bw.write(str1);
                bw.newLine();
                bw.flush();

                String str=br.readLine();
                System.out.println("从客户端收到"+str);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
